package com.eedi.framework.tenant.service;

import cn.hutool.core.util.ObjUtil;
import com.eedi.framework.tenant.controller.sys.vo.setup.SysSetupBasicReq;
import com.eedi.framework.tenant.controller.sys.vo.setup.SysSetupBasicResp;
import com.eedi.framework.tenant.dal.mapper.SysSetupBasicMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 基本设置
 * @author zybourn
 */
@Service
@Slf4j
public class SysSetupBasicServiceImpl implements SysSetupBasicService {
    @Resource
    SysSetupBasicMapper sysSetupBasicMapper;

    @Override
    public SysSetupBasicResp getSysSetupBasic() {
        return sysSetupBasicMapper.getSetupBasicResp();
    }

    @Override
    public void setup(SysSetupBasicReq req) {
        SysSetupBasicResp sysSetupBasic = getSysSetupBasic();
        if (ObjUtil.isNotNull(sysSetupBasic)){
            sysSetupBasicMapper.setup(sysSetupBasic.getSysSetupBasicId(),req);
            return;
        }
        sysSetupBasicMapper.insert(req);
    }
}
